package com.iflytek.jobs.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.iflytek.jobs.service.domain.JobQuest;
import com.iflytek.jobs.service.service.IJobQuestService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 面试题库Controller
 * 
 * @author chenhs
 * @date 2025-08-24
 */
@RestController
@RequestMapping("/jobs/quest")
public class JobQuestController extends BaseController
{
    @Autowired
    private IJobQuestService jobQuestService;

    /**
     * 查询面试题库列表
     */
    @GetMapping("/list")
    public TableDataInfo list(JobQuest jobQuest)
    {
        startPage();
        List<JobQuest> list = jobQuestService.selectJobQuestList(jobQuest);
        return getDataTable(list);
    }

    /**
     * 导出面试题库列表
     */
    @Log(title = "面试题库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JobQuest jobQuest)
    {
        List<JobQuest> list = jobQuestService.selectJobQuestList(jobQuest);
        ExcelUtil<JobQuest> util = new ExcelUtil<JobQuest>(JobQuest.class);
        util.exportExcel(response, list, "面试题库数据");
    }

    /**
     * 获取面试题库详细信息
     */
    @GetMapping(value = "/{jqId}")
    public AjaxResult getInfo(@PathVariable("jqId") String jqId)
    {
        return success(jobQuestService.selectJobQuestByJqId(jqId));
    }

    /**
     * 新增面试题库
     */
    @Log(title = "面试题库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JobQuest jobQuest)
    {
        return toAjax(jobQuestService.insertJobQuest(jobQuest));
    }

    /**
     * 修改面试题库
     */
    @Log(title = "面试题库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JobQuest jobQuest)
    {
        return toAjax(jobQuestService.updateJobQuest(jobQuest));
    }

    /**
     * 删除面试题库
     */
    @Log(title = "面试题库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jqIds}")
    public AjaxResult remove(@PathVariable String[] jqIds)
    {
        return toAjax(jobQuestService.deleteJobQuestByJqIds(jqIds));
    }
}
